package com.example.cloudalibabanacos9001.controller;

import com.example.cloudalibabanacos9001.entity.JsonResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class DemoController {
    //模仿数据库存储数据
    public static HashMap<Long,String> hashMap = new HashMap<>();
    static {
        hashMap.put(1l,"鼠标");
        hashMap.put(2l,"键盘");
        hashMap.put(3l,"耳机");
    }

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("info/{id}")
    public JsonResult<String> msbSql(@PathVariable("id") Long id){
        JsonResult<String> result = new JsonResult(Long.parseLong(serverPort), 200, hashMap.get(id));
        return result;
    }

    @GetMapping(value = "/msb/get")
    public String getServerPort() {
        return "库存-1：" + serverPort;
    }

    @GetMapping(value = "/msb/custom")
    public String customTest(){
        return "网关配置测试~~costom";
    }
}